package me.send.produce.data.controller;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import me.send.business.base.Pager;
import me.send.data.service.pojo.Finance;
import me.send.data.service.pojo.base.DatatablesViewPage;
import me.send.data.service.service.FinanceService;
import me.send.data.service.service.TreeService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping(value = "finance")
public class FinanceController {

	@Autowired
	private FinanceService financeService;

	@Autowired
	private TreeService treeService;


	// 查询提现订单列表
	@RequestMapping(value = "report/sum")
	public ModelAndView report_sum(HttpServletRequest request) {
		ModelAndView modelAndView = new ModelAndView(
				"stage/finance/finance_report");
		modelAndView.addObject("LoadTree",
				treeService.main_tree(0, request, "finance/report/sum"));
		modelAndView.addObject("module", "财务收支汇总报表");
		return modelAndView;
	}

	
	@RequestMapping(value="report/sum/data")  
    @ResponseBody  
    public DatatablesViewPage<Finance> finance_data(HttpServletRequest request){  
//获取分页控件的信息  
        String start = request.getParameter("start");  
        String length = request.getParameter("length"); 
//获取前台额外传递过来的查询条件  
        
        Pager page=new Pager();
        Integer row=Integer.parseInt(length);
        page.setRows(row);
        Integer startInt=Integer.parseInt(start);
        Integer p=(startInt/row)+1;
        page.setPage(p);
        
                //随便组织的查询结果  
        List<Finance> list=new ArrayList<Finance>();
        list.add(financeService.queryFinanceReport());
        DatatablesViewPage<Finance> view = new DatatablesViewPage<Finance>();  
        view.setiTotalDisplayRecords(1);  
        view.setiTotalRecords(1);  
          
        view.setAaData(list);  
        return view;  
    }  
	
}
